package bajo.src;

import java.util.Date;

import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class Post extends ButtonField {
	private String poster; // Name of the user who posted this message.
	private String postedDate; // Date at which this message is posted.
	private String msg; // Message.
	private String postId; //id of the post;
	
	private LabelField msgInfo;
	private LabelField msgString;
	private VerticalFieldManager uiMsg;
	
	private int butWidth;
	private int butHeight;
	
	public Post(String butText, int width, int height){
		super(butText);
		poster = "null";
		postedDate = "";
		msg = "null";
		
		butWidth = width;
		butHeight = height;
	}
	
	public Post(String poster, String postedDate, String msg, String postId, String butText, 
						int width, int height){
		super(butText);
		this.poster = poster;
		this.postedDate = postedDate;
		this.msg = msg;	
		this.postId = postId;
		
		butWidth = width;
		butHeight = height;
	}
	
	/*
	 * This function returns the VerticalFieldManager of a single post in the
	 * course.
	 */
	public VerticalFieldManager getPost() {
		uiMsg = new VerticalFieldManager(VerticalFieldManager.FOCUSABLE);
		
		msgInfo = new LabelField("By: " + poster + "\nDate: " + postedDate + "\n\n");
		msgInfo.setFont(Font.getDefault().derive(Font.BOLD, 20));
		msgString = new LabelField(msg, LabelField.FOCUSABLE);
		msgString.setFont(Font.getDefault().derive(Font.PLAIN, 20));
		
		uiMsg.add(msgInfo);
		uiMsg.add(msgString);
		return uiMsg;
	}
	
	/*
	 * Set the height of the button to the specific value.
	 */
	public int getPreferredHeight() {
		return butHeight;
	}
	
	/*
	 * Set the width of the button to the specified value.
	 */
	public int getPreferredWidth() {
		return butWidth;
	}
	
	/*
	 * Return the user's ID of the poster in String.
	 */
	public String getPoster() {
		return poster;
	}
	public String getPostId() {
		return postId;
	}
	
}
	